Add secondary basemap upload. From Bernhard Nebel.
authorrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Tue, 2 Dec 2003 15:12:26 +0000 (15:12 +0000)
committerrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Tue, 2 Dec 2003 15:12:26 +0000 (15:12 +0000)
magxfer/Makefile
magxfer/README
magxfer/magxfer.c

index 5db1ecde913bbb057a61174691812e25bf67748d..1507d9d6abd0ed6be216d8d3cce20764e04077fe 100644 (file)
@@ -5,8 +5,8 @@ magxfer: magxfer.c
 clean:
        rm -f magxfer
 
-VERSIONU=1_0_0
-VERSIOND=1.0.0
+VERSIONU=1_0_1
+VERSIOND=1.0.1
 release:
        cvs tag magxfer_$(VERSIONU)
        cvs export -r magxfer_$(VERSIONU) -d magxfer-$(VERSIOND) magxfer
index 1fccd2fa8c66a1ff6a4e92bbe561a39db34701ec..b7286074593dba84fa37f704fade91731ce13763 100644 (file)
@@ -11,7 +11,7 @@ utility to shoot them into your receiver.  The files you need are in the
 
 Usage is simple:
 
-       magxfer [-p portname] [-b bitrate] -f filetosend.img
+       magxfer [-p portname] [-b bitrate] [-t type ] -f filetosend.img
 
        portname specifies the serial port to use.  The default 
                is "/dev/ttyS0" which is the first serial port on a 
@@ -21,6 +21,10 @@ Usage is simple:
                default is 4800.   After connection is made, the actual
                transfer happens at 115200 bps, regardless of this option.
 
+       type    can be d for detailed map or s for secondary base map such
+               as by Worldwide Basemap or p for primary basemap.  Default
+               is d. 
+
        filetosend.img is the image file you wish to upload to the unit.
                
 
index 4cef3981cbde1733a59d4c084b99f7b95d9d2acb..12991958deae72f76625cbed4d2da55fc670e9df 100644 (file)
@@ -41,6 +41,22 @@ typedef struct {
 void dump_xframe(vld *frame);
 void send_terminate(void);
 
+const char *usagestring = "\
+Usage: magxfer [-p portname] [-b bitrate] [-t type ] -f filetosend.img\n\
+       portname   port for uplkoad (default /dev/ttyS0)\n\
+       bitrate    bitrate (default is 4800)\n\
+       type       can be \n\
+                               b (secondary base map),\n\
+                       B (primary base map), or\n\
+                       d (detailed map)\n\
+                  (default d)\n\
+       filetosend.img is the image file you wish to upload to the unit\n";
+void 
+usage()
+{
+    fprintf(stderr,"%s",usagestring);
+}
+
 void
 debug(const char *fmt, ...)
 {
@@ -443,10 +459,14 @@ setup_port(const char *portname, unsigned bitrate)
  * the data.
  */
 void
-send_upload_cmd(void)
+send_upload_cmd(unsigned detailed)
 {
-#define MU_CMD "$PMGNCMD,MPUPLOAD,2*72\r\n"
-       write(magfd, MU_CMD, sizeof(MU_CMD));
+       static const char *cmd[] = {
+               "$PMGNCMD,MPUPLOAD,1*71\r\n", 
+               "$PMGNCMD,MPUPLOAD,2*72\r\n", 
+               "$PMGNCMD,MPUPLOAD,3*73\r\n",
+       };
+       write(magfd, cmd[detailed], strlen(cmd[detailed] + 1));
        cfsetospeed(&new_tio, B115200);
        cfsetispeed(&new_tio, B115200);
        tcsetattr(magfd, TCSADRAIN, &new_tio);
@@ -506,18 +526,32 @@ sync_receiver(void)
 int
 main(int argc, char *argv[])
 {
-       static  char ibuf[10000000];
+       static  char ibuf[64*1024*1024];
        unsigned short cksum;
        size_t file_sz;
        size_t sent_sz;
        FILE *inf;
        int c;
        unsigned bitrate = 4800;
+       int detailedmap = 1;
        const char *portname = "/dev/ttyS0";
-       const char *ifilename = "/dev/ttyS0";
+       const char *ifilename = "";
+
 
-       while ((c = getopt(argc, argv, "f:p:b:D:")) != EOF) {
+       while ((c = getopt(argc, argv, "t:f:p:b:D:")) != EOF) {
                switch(c) {
+                       case 't':
+                           if (strcmp(optarg,"s") == 0)
+                               detailedmap = 2;
+                           else if (strcmp(optarg,"d") == 0)
+                               detailedmap = 1;
+                           else if (strcmp(optarg,"p") == 0)
+                               detailedmap = 0;
+                           else {
+                               fprintf(stderr,"Map type (-t option) can only be 'd', 'p', or 's'\n");
+                               exit(1);
+                           }
+                           break;
                        case 'p':
                                portname = optarg;
                                break;
@@ -531,11 +565,18 @@ main(int argc, char *argv[])
                                bitrate = atoi(optarg);
                                break;
                        default:
+                               usage();
+                               exit(1);
                                break;
                }
        }
+       if (ifilename[0] == '\0') {
+               fprintf(stderr, "No input file specified. Exiting.\n");
+               usage();
+               exit(1);
+       }
        setup_port(portname, bitrate);
-       send_upload_cmd();
+       send_upload_cmd(detailedmap);
        sync_receiver();
 
        inf = fopen(ifilename, "r");
@@ -543,7 +584,7 @@ main(int argc, char *argv[])
        if (file_sz == sizeof(ibuf)) {
                fprintf(stderr, "File '%s' bigger than %d bytes.  Exiting.\n",
                        ifilename, sizeof(ibuf));
-
+               exit(1);
        }
 
        cksum = xor_checksum(ibuf, file_sz);